package zpin.dao;


import org.hibernate.Query;

import util.dao.HibernateDaoImpl;
import zpin.model.Authorization;
import zpin.model.Person;

public class PersonDaoImpl extends HibernateDaoImpl<Person, Long> implements PersonDao{

	public Person findByFk(Authorization authorization) {
		System.out.println("authorization的ID，account，password是"+authorization.getId()+authorization.getAccount()+authorization.getPassword());
		
		System.out.println("看看session"+this.getSession());
		
		System.out.println("query是："+this.getSession().createQuery("from "+Person.class.getName()+" p where p.authorization.id="+authorization.getId()));
		
		Query query = this.getSession().createQuery("from "+Person.class.getName()+" p where p.authorization.id="+authorization.getId());
		if(query.uniqueResult()!=null){
			return (Person) query.list().get(0);
		}else{
			return null;
		}
	}

}
